<%@ page contentType="text/html;charset=UTF-8" %>
<%--<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>--%>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录界面</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="app" class="container">
    <div class="row">
        <div class="col-md-4"></div>
        <%--<form action="/demo/stuInfo/add" method="post">--%>
            <div class="col-md-4">
                <p class="h1 text-center">增加</p>
                <div>
                    <input type="text" name="stuId" class="form-control" v-model="stuInfo.stuId"  placeholder="学号">
                </div>
                <br>
                <div>
                    <input type="text" name="name" class="form-control"  v-model="stuInfo.name" placeholder="姓名">
                </div>
                <br>
                <div>
                    <input type="text" name="sex" class="form-control" v-model="stuInfo.sex" placeholder="性別">
                </div>
                <br>
                <div>
                    <input type="text" name="clazz" class="form-control"  v-model="stuInfo.clazz"  placeholder="班级">
                </div>
                <br>
                <div>
                    <input type="text" name="birth" class="form-control" v-model="stuInfo.birth" placeholder="出生日期">
                </div>
                <br>
                <div>
                    <input type="text" name="address" class="form-control" v-model="stuInfo.address" placeholder="地址">
                </div>
                <br>
                <div>
                    <input type="text" name="postalcode" class="form-control" v-model="stuInfo.postalcode" placeholder="邮编">
                </div>
                <br>
                <div>
                    <input type="text" name="phone" class="form-control" v-model="stuInfo.phone" placeholder="电话">
                </div>
                <br>
                <div>
                    <input type="text" name="beginTime" class="form-control" v-model="stuInfo.beginTime" placeholder="入学时间">
                </div>
                <br>
                <div>
                    <input type="text" name="remark" class="form-control" v-model="stuInfo.remark" placeholder="评价">
                </div>
                <br>
                <button @click="add()" type="submit" class="btn btn-info btn-block" >提交</button>
            </div>
        <%--</form>--%>
        <div class="col-md-4">
        </div>
    </div>

</div>

<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script src="/static/js/vue.js"></script>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            stuInfo: {
                stuId: null,
                name: '',
                sex: '',
                clazz: null,
                birth: null,
                address: '',
                postalcode: null,
                phone: '',
                beginTime: null,
                remark: ''
            },
            result: ''

        },
        methods: {
           add:function () {
               $.ajax({
                   url:'/demo/stuInfo/add',
                   // url:'https://www.baidu.com',
                   type:'POST',
                   contentType:'application/json',
                   data:JSON.stringify(app.stuInfo),
                   dataType:'json',
                   // data:{"stuInfo":this.stuInfo},
                   success:function(result){
                       this.result = result;
                       var url = '/demo/stuInfo/index';
                       if(result.indexOf("成功")>=0){
                           window.location.href='/demo/stuInfo/success?result='+this.result+'&url=' + url;
                       }else{
                           window.location.href= '/demo/stuInfo/error?result='+this.result+'&url=' + url;
                       }
                   }
               });
           }
        }
    });
</script>
</body>
</html>